<template>
  <div class="comer">
    <CommonHeader :propdatas="1"></CommonHeader>
    <div class="homnav">
      <img src="../assets/images/homnav.png" alt="" class="homnavpng">
    </div>
    <div class="all">
    <div class="naver">
       <div class="tit">条件筛选</div>
       <div class="linearea">
         <span class="areanav">区域</span>
         <span v-for="(item,index) in list" :key="index" :class="choosen==index?'red':'normal'" @click="chosecity(item,index)">{{item.areaName}}</span>
       </div>
    </div>
    <div class="result">
      共找到 <span style="color:#F22525">{{ dataCount }}</span>个符合条件的楼盘
    </div>
      <div class="resultlistall">
         <div class="resultline" v-for="(item,index) in listline" :key="index"  @click="Seedetails(item)">
           <div class="lineleft">
             <div class="leftimg">
               <img :src="item.imageCover" alt="" class="leftimgstyle">
             </div>
             <div class="leftright">
               <div class="tit">
                 {{ item.name }}
                 <span class="nowsell">{{ item.sellState }}</span>
               </div>
               <div class="minitip">
                 <span class="minitipleft">地址</span>
                 <span class="minitipright">{{ item.address }}</span>
                 <img src="../assets/images/dizhi.png" alt="" class="minitipimg">
               </div>
               <div class="minitip">
                 <span class="minitipleft">户型</span>
                 <span class="minitipright" v-if="item.householdType!=null">{{  item.householdType }}</span>
                 <span class="minitipright" v-else>暂未公布</span>
               </div>
               <div class="minitip">
                 <span class="minitipleft">建面</span>
                 <span class="minitipright" v-if="item.houseArea!=null">{{ item.houseArea}}</span>
                 <span class="minitipright" v-else>暂未公布</span>
               </div>
               <div class="lastminitip">
                  <span v-for="(item,index) in item.houseLabelList" :key="index" class="lastmini">{{item.labelContent}}</span>
               </div>
             </div>
           </div>
           <div class="lineright">
              <div class="rightlineone">最高补贴 <span style="font-size: 24px;color: #F22525">{{item.subsidyStart}}</span>m²m²/套</div>
              <div class="rightlinetwo">历史均价：{{ item.averagePrice }}m²</div>
              <div class="rightlinethree" @click="Seedetails(item)"><span class="look">查看详情</span></div>
<!--             <div class="rightlinethree" @click="seeeeeee"><span class="look">查看详情</span></div>-->
           </div>
         </div>

      </div>
      <!-- 分页 -->
      <div id="app" class="fengye">
        <el-pagination
            :page-size="pageSize"
            @current-change="handleCurrentChange"
            background
            layout="prev, pager, next"
            :total="dataCount">
        </el-pagination>
      </div>

  </div>

    <CommonBottom></CommonBottom>
  </div>
</template>

<script>
import 'element-plus/lib/theme-chalk/index.css';
import CommonHeader from '../components/commonHeader'
import CommonBottom from "@/components/commonBottom";
import {updateFrontUser,updateUser} from "@/api/vip";
export default {
  name:'Home',
  components:{
    CommonBottom,
    CommonHeader,
    // Carousel
  },
  data(){
    return{
      areaName:[],
      dataCount:'',
      pagination: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
      chosenKind:'',
      kindList:[
        {name:"首页",value:0},
        {name:"楼盘查询",value:1},
        {name:"加入我们",value:2},
        {name:"下载APP",value:3},
      ],
      list:[],
      listline:[],
      choosen:null,
      pageNum:1,
      pageSize:10,

    }
  },
  mounted() {
    this.getall()
    this.gethouse()
  },
  methods:{
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      const _this = this;
      this.pageNum=val
      _this.gethouse(val)   // 调取列表的函数，初始化时调一次。
    },
    getall(){
      const time =this.time();
      let params = {
        action:'code.getInneCity',
        timestamp: time,
        signature: this.clos_encryptDes("code.getInneCity", time),
        accessKeyId: "APId1482c4fc9",
        deviceId:'1',
        cityId:localStorage.getItem('cityId'),
      }
      updateFrontUser(params).then(
          (res) => {
            if (res.data.statusCode == 201 && res.data.success == true) {
              this.list=res.data.data
              console.log(this.list,'list')
            }else{
              this.loading = false;
            }
          }).catch((error) => {
        console.log(error,'99');

      });
    },
    seeeeeee(){
      this.$message({
        type: 'success',
        message: "正在升级，敬请期待"
      });
    },
    gethouse(val){
      const time =this.time();
      let params = {
        action:'website.getHouseListContainCondition',
        timestamp: time,
        signature: this.clos_encryptDes("website.getHouseListContainCondition", time),
        accessKeyId: "APId1482c4fc9",
        deviceId:'1',
        cityId:localStorage.getItem('cityId'),
        area:JSON.stringify(this.areaName),
        pageNum:this.pageNum,
        pageSize:this.pageSize
      }
      updateUser(params).then(
          (res) => {
            if (res.data.statusCode == 201 && res.data.success == true) {
              this.listline=res.data.data.rs
              this.dataCount=res.data.data.dataCount
            }else{
              this.loading = false;
            }
          }).catch((error) => {
        console.log(error,'99');

      });
    },
    chosecity(item,index){
      this.choosen=index
      this.areaName.push(item.areaName)
      console.log(item,'item')
      this.gethouse()
    },
    Seedetails(item){
      console.log(item.id,'参数')
      localStorage.setItem('houseId',item.id);
      this.$router.push({
        name: 'detail',
        // params:{
        //   houseId:item.id,
        // }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.comer{
  .homnav{
    width: 100%;
    height:80px;
   .homnavpng{
     width: 100%;
     height:80px;
   }
  }
  .all{
    padding:0 190px;

  .naver{
    text-align: left;
    .tit{
      height: 60px;
      font-size: 18px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      color: #141414;
      line-height: 60px;
    }
    .linearea{
      .areanav{
        background: #F8F8F8;
        border: 1px solid #EEEEEE;
        height: 48px;
        font-size: 16px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #999999;
        line-height: 48px;
        padding: 6px;
        margin-right: 10px;
      }
      .red{
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #F22525;
        margin-right: 10px;
        cursor:pointer;
      }
      .normal{
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #141414;
        margin-right: 10px;
        cursor:pointer;
      }
    }
  }
  .result{
      height: 60px;
      font-size: 18px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      color: #141414;
      line-height: 60px;
      border-bottom: 1px solid #E0E0E0;
      text-align: left;
      margin-top: 40px;
    }
    .fengye{
     float: right;
      height: 80px;
      vertical-align: middle;
      margin-top: 30px;
    }
  .resultlistall{
    .resultline{
      display: flex;
      justify-content: space-between;
      margin-top: 30px;
      .lineleft{
        display: flex;
        justify-content: flex-start;
        .leftimg{
          .leftimgstyle{
            width: 260px;
            height: 180px;
          }
        }
        .leftright{
          text-align: left;
          margin-left: 20px;
          .tit{
            //height: 23px;
            font-size: 20px;
            font-family: Source Han Sans CN;
            font-weight: bold;
            color: #141414;
            //line-height: 50px;
            .nowsell{
              display: inline-block;
              background: #3388FF;
              border-radius: 3px;
              height: 11px;
              line-height: 11px;
              padding:5px 5px;
              font-size: 12px;
              font-family: Source Han Sans CN;
              font-weight: 300;
              color: #FFFFFF;
            }
          }
          .minitip{
            height: 37px;
            font-size: 14px;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #666666;
            line-height: 37px;
            .minitipleft{
              display: inline-block;
              width: 46px;
            }
            .minitipright{

            }
            .minitipimg{
              width: 13px;
              height: 15px;
              margin-left: 3px;
            }
          }
          .lastminitip{
            margin-top: 17px;
            .lastmini{
              display: inline-block;
              background: #F1F7FF;
              border-radius: 3px;
              padding: 2px 5px;
              font-size: 12px;
              font-family: Source Han Sans CN;
              font-weight: 300;
              color: #666666;
              margin-right: 5px;
            }
          }
        }
      }
      .lineright{
        text-align: right;
        .rightlineone{
          height: 40px;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: bold;
          color: #F22525;
          line-height: 40px;
          margin-top: 30px;
        }
        .rightlinetwo{
          height: 50px;
          font-size: 16px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #666666;
          line-height: 50px;
        }
        .rightlinethree{
          margin-top: 25px;
          &:hover{
            cursor:pointer
          }
          .look{
            display: inline-block;
            width: 67px;
            height: 25px;
            background: #FFFFFF;
            border: 1px solid #3388FF;
            border-radius: 3px;
            font-size: 14px;
            font-family: Source Han Sans CN;
            font-weight: 300;
            color: #3388FF;
            line-height: 25px;
            text-align: center;
          }
        }
      }
    }
  }
  }
}

</style>
